require('@babel/polyfill')

// 导入单个组件
import { Basicform, DynamicForm, FormItem } from './Basicform/index'
import BatchProcessing from './BatchProcessing/index'
import { DataTable, Toolbar } from './DataTable/index'
import DatetimeRange from './DatetimeRange/index'
import DoingDialog from './DoingDialog/index'
import InnerTable from './InnerTable/index'
import LRLayout from './LRLayout/index'
import LeftPanel from './LRLayout/src/LeftPanel'
import RightPanel from './LRLayout/src/RightPanel'
import PageContent from './PageContent/index'
import PageHeader from './PageHeader/index'
import PdfTools from './PdfTools'
import ResRoles from './ResRoles/index'
import RichtextEditor from './RichtextEditor'
import ScrollPane from './ScrollPane/index'
import SelectDialog from './SelectDialog/index'
import SelectGroup from './SelectGroup/index'
import SidebarLogo from './SidebarLogo/index'
import SvgIcon from './SvgIcon/index'
import WfNames from './WfNames/index'
import { Attachment, BodyFile, CommandBar, HandleIdea, IdeaInputBox, ModifyWflogAddUser, ModifyWflogSubmitFile, ModifyWflogIdea, WriteToReadIdea, ModifyWfNodelog, SelectOuterDeputy, SubmitHandle, SubmitDialog, WfNodelogList, WflowView, ImgView, IdeaSignature, ReplaceFile, ViewBodyFile } from './Wflowform'
import './Directive/index'
import lang from './lang/index'

// 以数组的结构保存组件，便于遍历
const components = [
    Basicform, BatchProcessing, DynamicForm, FormItem, DataTable, Toolbar, DatetimeRange, DoingDialog, InnerTable, LRLayout, LeftPanel, RightPanel, PageHeader, PageContent, PdfTools, ResRoles, RichtextEditor, ScrollPane, SelectDialog, SelectGroup, SidebarLogo, SvgIcon, WfNames,
    Attachment, BodyFile, CommandBar, HandleIdea, IdeaInputBox, ModifyWflogAddUser, ModifyWflogSubmitFile, ModifyWflogIdea, WriteToReadIdea, ModifyWfNodelog, SelectOuterDeputy, SubmitHandle, SubmitDialog, WfNodelogList, WflowView, ImgView, IdeaSignature, ReplaceFile, ViewBodyFile
]

// 定义 install 方法
const install = function(Vue) {
    if (install.installed) return
    install.installed = true
    // 遍历并注册全局组件
    components.map(component => {
        Vue.component(component.name, component)
    })
}

if (typeof window !== 'undefined' && window.Vue) {
    install(window.Vue)

    setTimeout(() => {
        window.$alert = window.Vue.prototype.$alert
    }, 0)
}

export default {
    // 导出的对象必须具备一个 install 方法
    install,
    // 组件列表
    ...components
}

export const i18n = lang
